.editor {
  display: grid;
  width: 100%;
  min-height: 0;
  grid-template: auto / 1fr;

  &:after {
    content: attr(data-value) " ";
    visibility: hidden;
  }

  :global(.line) {
    display: inline-block;
    width: calc(100% + 32px);
    padding: 0 16px;
    margin: 0 -16px;
    transition:
      width 0.2s,
      padding 0.2s,
      margin 0.2s;

    &:before {
      position: relative;
      left: 6px;
      display: inline-block;
      width: 1rem;
      margin-right: 1.5rem;
      margin-left: -2.5rem;
      color: var(--line-number);
      content: attr(data-line);
      opacity: 0;
      text-align: right;
      transition: opacity 0.2s;
    }
  }

  :global(.highlighted-line) {
    position: relative;
    background-color: var(--ray-highlight) !important;

    &:after {
      position: absolute;
      top: 0;
      bottom: 0;
      left: -1px;
      width: 2px;
      background-color: var(--ray-highlight-border);
      content: "";
    }
  }
}

.isHighlightingLines {
  :global(.line):hover {
    background-color: var(--ray-highlight-hover);
    cursor: default;
  }
  .textarea {
    z-index: -1;
  }
}

.textarea,
.formatted,
.editor:after {
  padding: var(--editor-padding);
  margin: 0;
  counter-increment: step 0;
  counter-reset: step;
  font-family: inherit;
  font-size: 15px;
  font-variant-ligatures: none;
  font-weight: inherit;
  grid-area: 1 / 1 / 2 / 2;
  letter-spacing: 0.1px;
  line-height: 22.5px;
  tab-size: 2;
  transition: padding 0.2s;
  white-space: pre-wrap;
}

.showLineNumbers {
  --line-number-padding: 3rem;
  .textarea,
  .formatted,
  .editor:after {
    padding-left: var(--line-number-padding);
  }

  :global(.line) {
    width: calc(100% + 16px + var(--line-number-padding));
    padding: 0 16px 0 var(--line-number-padding);
    margin: 0 -16px 0 calc(-1 * var(--line-number-padding));

    &:before {
      opacity: 1;
    }
  }

  &.showLineNumbersLarge {
    --line-number-padding: 3.5rem;
  }
}

.textarea {
  z-index: 2;
  overflow: hidden;
  min-height: min-content;
  border: none;
  background: transparent;
  caret-color: var(--ray-foreground);
  resize: none;
  -webkit-text-fill-color: transparent;
  text-size-adjust: none;

  &:focus {
    border: none;
    outline: none;
  }
}

.formatted > pre {
  margin: 0;
  background-color: initial !important;
  font-family: inherit;
  white-space: pre-wrap;
}

.formatted > pre > code {
  font-family: inherit;
}

.plainText {
  color: var(--ray-foreground);
}

.jetBrainsMono {
  font-family: var(--font-jetbrainsmono), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", monospace;
  font-weight: 500;
}

.ibmPlexMono {
  font-family: var(--font-ibmplexmono), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", monospace;
  font-weight: 500;
}

.firaCode {
  font-family: var(--font-firacode), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", monospace;
  font-weight: 400;
}

.geistMono {
  font-family: var(--font-geist-mono), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", monospace;
  font-weight: 400;
}

.soehneMono {
  font-family: var(--font-soehne-mono), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", monospace;
  font-weight: 400;
}

.robotoMono {
  font-family: var(--font-roboto-mono), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", monospace;
  font-weight: 400;
}

.commitMono {
  font-family: var(--font-commitmono), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", monospace;
  font-weight: 400;
}

.spaceMono {
  font-family: var(--font-space-mono), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", monospace;
  font-weight: 400;
}
